package router

import (
	"github.com/RaymondCode/simple-demo/controller"
	"github.com/RaymondCode/simple-demo/middleware"
	"github.com/cloudwego/hertz/pkg/app/server"
)

func InitRouter(h *server.Hertz) {
	// 静态资源服务
	h.Static("/static", "./public")

	// 非鉴权
	noAuth := h.Group("/douyin")
	// 用户注册与登陆
	user2 := noAuth.Group("/user")
	{
		user2.POST("/register/", controller.Register)
		user2.POST("/login/", controller.Login)
	}

	// 鉴权
	withAuth := h.Group("/douyin", middleware.JWTAuth, middleware.SaveUserId)
	// 视频流接口
	withAuth.GET("/feed/", controller.Feed)
	// 用户信息接口
	user1 := withAuth.Group("/user")
	{
		user1.GET("/", controller.UserInfo)
	}
	// 视频上传
	publish := withAuth.Group("/publish")
	{
		publish.GET("/list/", controller.VideoList)
		publish.POST("/action/", controller.Publish)
	}
	// 点赞
	favorite := withAuth.Group("/favorite")
	{
		favorite.GET("/list/", controller.FavoriteList)
		favorite.POST("/action/", controller.Like)
	}
	// 评论
	comment := withAuth.Group("/comment")
	{
		comment.GET("/list/", controller.CommentList)
		comment.POST("/action/", controller.Comment)
	}
	// 关系
	relation := withAuth.Group("/relation")
	{
		relation.GET("/follow/list/", controller.FollowList)
		relation.GET("/follower/list/", controller.FansList)
		relation.GET("/friend/list", controller.FriendList)
		relation.POST("/action/", controller.Follow)
	}
	// 消息
	message := withAuth.Group("/message")
	{
		message.GET("/chat/", controller.MessageChat)
		message.POST("/action/", controller.MessageAction)
	}
}
